package mobil.indkoebsliste;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class mall extends Activity {
	Dao dao = Dao.getInstance();
	ArrayList<Vare> listItems = dao.getButiksListe();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mall);
		ArrayAdapter<Vare> adapter = new ArrayAdapter<Vare>(this,
				android.R.layout.simple_list_item_1, listItems);
		final ListView lv = (ListView) findViewById(R.id.mall_list);

		lv.setAdapter(adapter);

		lv.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> myAdapter, View myView,
					int myItemInt, long mylng) {
				Vare selectedFromList = (Vare) (lv.getItemAtPosition(myItemInt));
				dao.addToIndkoebsliste(selectedFromList);
			}
		});

	}
}
